<!DOCTYPE html>
<html lang="zh-cmn-Hans">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>导航</title>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=4QlvWVGVYREqtgpQOmDwRBXCEiWNRpGd"></script>  
    <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script><!--调用jQuery-->

  <style type="text/css">
        body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
    </style> 

</head>

<body>  
   <div id="allmap"></div>
</body>  
</html>  
<script type="text/javascript">  

    var map = new BMap.Map("allmap");  
    var point = new BMap.Point("梅州市");
    map.centerAndZoom(point, 16);  
    map.enableScrollWheelZoom(); 

	 translateCallback = function (data){
      if(data.status === 0) {
       	
        var x1 = data.points[0].lng;
        var y1 = data.points[0].lat;
        location.href="http://api.map.baidu.com/direction?origin="+y1+","+x1+"&destination=<?php echo $_GET['address'] ?>&mode=driving&region=梅州&output=html";
      }
    }

    var geolocation = new BMap.Geolocation();
    geolocation.getCurrentPosition(function(r){
        if(this.getStatus() == BMAP_STATUS_SUCCESS){
            var mk = new BMap.Marker(r.point);
            map.addOverlay(mk);
            map.panTo(r.point);//地图中心点移到当前位置
            var latCurrent = r.point.lat;
            var lngCurrent = r.point.lng;
            //alert('我的位置：'+ latCurrent + ',' + lngCurrent);
//          var x = lngCurrent;
//		    var y = latCurrent;
//		    var ggPoint = new BMap.Point(x,y);
//			var convertor = new BMap.Convertor();
//	        var pointArr = [];
//	        pointArr.push(ggPoint);
//	        convertor.translate(pointArr, 1, 5, translateCallback)            
			location.href="http://api.map.baidu.com/direction?origin="+latCurrent+","+lngCurrent+"&destination=<?php echo $_GET['address'] ?>&mode=driving&region=梅州&output=html";
        }
        else {
            alert('failed'+this.getStatus());
        }        
    },{enableHighAccuracy: true})

</script>